
*************************************************
* Summary Stats - Table 2 Panel A
*************************************************
use baseline.dta, clear

estpost summarize y_pollution d_pollution regulatory_risk PE_target PE_drillco d_sensible FracturingDuration horizontallength verticaldepth first6oil first6gas confidential d_confidential, detail


*************************************************
* Summary Stats - Table 2 Panel B
*************************************************
use baseline.dta, clear

bys Statefips id_OG: gen presence_state=[_n]

replace presence_state=0 if presence_state>1

bys lat_long1 id_OG: gen presence_location=[_n]

replace presence_location=0 if presence_location>1

collapse (sum) projects presence_state presence_location, by (id_OG)

estpost summarize projects presence_state presence_location, detail

*************************************************
* Summary Stats - Table 3 Panel A
*************************************************
use baseline.dta, clear
drop if year<2015
local variables "y_pollution d_pollution PE_target PE_drillco FracturingDuration horizontallength verticaldepth first6gas first6oil confidential d_confidential"
eststo clear
estpost ttest `variables', by(d_sensible) unequal
esttab , noobs cells("b(star fmt(4)) se(fmt(4)) count(fmt(0))") star(* 0.1 ** .05 *** 0.01) collabels("Diff." "Std. Error" "Obs.")
estpost sum `variables' if d_sensible==1
matrix meanf1=e(mean)
matrix list meanf1
estpost sum `variables' if d_sensible==0
matrix meanf0=e(mean)
matrix list meanf0
estpost ttest `variables', by(d_sensible) unequal
estadd matrix meanf1
estadd matrix meanf0
esttab, label noobs cells("meanf1(fmt(4)) meanf0(fmt(4)) b(star fmt(4)) p(fmt(4)) count(fmt(0))") star(* 0.1 ** .05 *** 0.01) collabels("Group treated" "Control group" "Diff." "p" "Obs.") replace

*To obtain the clustered diff:
foreach t of local variables {
reghdfe `t' d_sensible, absorb(cst) vce (cluster id_OG)
}

*Differences with the controls:
foreach t of local variables {
 reghdfe `t' d_sensible, absorb(lat_long1_year state_year) vce (cluster id_OG)
}

*************************************************
* Summary Stats - Table 3 Panel B
*************************************************
use baseline.dta, clear

drop if post==1
local variables "y_pollution d_pollution high_liability regulatory_risk  FracturingDuration d_sensible horizontallength verticaldepth first6oil first6gas confidential d_confidential"
eststo clear
estpost ttest `variables', by(PE_target) unequal
esttab , noobs cells("b(star fmt(4)) se(fmt(4)) count(fmt(0))") star(* 0.1 ** .05 *** 0.01) collabels("Diff." "Std. Error" "Obs.")
estpost sum `variables' if PE_target==1
matrix meanf1=e(mean)
matrix list meanf1
estpost sum `variables' if PE_target==0
matrix meanf0=e(mean)
matrix list meanf0
estpost ttest `variables', by(PE_target) unequal
estadd matrix meanf1
estadd matrix meanf0
esttab, label noobs cells("meanf1(fmt(4)) meanf0(fmt(4)) b(star fmt(4)) p(fmt(4)) count(fmt(0))") star(* 0.1 ** .05 *** 0.01) collabels("Group treated" "Control group" "Diff." "p" "Obs.") replace

*To obtain the clustering diff:
foreach t of local variables {
reghdfe `t' PE_target, absorb(cst) vce (cluster id_OG)
}

*With the controls:
foreach t of local variables {
 reghdfe `t' PE_target, absorb(lat_long1_year state_year) vce (cluster id_OG)
}

*************************************************
*Table 4 Panel A
*************************************************
use baseline.dta, clear

local dependent "y_pollution"
sum `dependent' 

reghdfe `dependent' c.post  contstd_*, absorb(id_OG state_year lat_long1_year) vce (cluster id_OG)

reghdfe `dependent' c.post#c.regulatory_risk contstd_*, absorb(id_OG_year state_year lat_long1_year) vce (cluster id_OG)

reghdfe `dependent' c.post#c.high_liability contstd_*, absorb(id_OG_year state_year lat_long1_year) vce (cluster id_OG)

local dependent "d_pollution"
sum `dependent' 

reghdfe `dependent' c.post contstd_*, absorb(id_OG state_year lat_long1_year) vce (cluster id_OG)

reghdfe `dependent' c.post#c.regulatory_risk contstd_*, absorb(id_OG_year state_year lat_long1_year) vce (cluster id_OG)

reghdfe `dependent' c.post#c.high_liability contstd_*, absorb(id_OG_year state_year lat_long1_year) vce (cluster id_OG)

*************************************************
*Table 4 Panel B
*************************************************
use matching_stacked_buyout.dta, clear

local dependent "y_pollution"
sum `dependent' 

reghdfe `dependent' c.post  contstd_*, absorb(id_OG_pair state_year_pair lat_long1_year_pair) vce (cluster id_OG)

reghdfe `dependent' c.post#c.regulatory_risk  contstd_*, absorb(id_OG_year_pair state_year_pair lat_long1_year_pair) vce (cluster id_OG)

reghdfe `dependent' c.post#c.high_liability  contstd_*, absorb(id_OG_year_pair state_year_pair lat_long1_year_pair) vce (cluster id_OG)

**Net Effect:
local dependent "d_pollution"
sum `dependent' 

reghdfe `dependent' c.post  contstd_*, absorb(id_OG_pair state_year_pair lat_long1_year_pair) vce (cluster id_OG)

reghdfe `dependent' c.post#c.regulatory_risk  contstd_*, absorb(id_OG_year_pair state_year_pair lat_long1_year_pair) vce (cluster id_OG)

reghdfe `dependent' c.post#c.high_liability  contstd_*, absorb(id_OG_year_pair state_year_pair lat_long1_year_pair) vce (cluster id_OG)


*************************************************
*Table 5 Panel A
*************************************************
use baseline.dta, clear

local dependent "y_pollution"
sum `dependent' 

reghdfe `dependent'  c.p_drillco contstd_*, absorb(id_OG state_year lat_long1_year) vce (cluster id_OG)

reghdfe `dependent'  c.p_drillco#c.regulatory_risk contstd_*, absorb(id_OG_year state_year lat_long1_year) vce (cluster id_OG)

reghdfe `dependent'  c.p_drillco#c.high_liability contstd_*, absorb(id_OG_year state_year lat_long1_year) vce (cluster id_OG)

local dependent "d_pollution"
sum `dependent' 

reghdfe `dependent'  c.p_drillco contstd_*, absorb(id_OG state_year lat_long1_year) vce (cluster id_OG)

reghdfe `dependent'   c.p_drillco#c.regulatory_risk contstd_*, absorb(id_OG_year state_year lat_long1_year) vce (cluster id_OG)

reghdfe `dependent'   c.p_drillco#c.high_liability contstd_*, absorb(id_OG_year state_year lat_long1_year) vce (cluster id_OG)

*************************************************
*Table 5 Panel B
*************************************************
use matching_stacked_drillco.dta, clear

local dependent "y_pollution"
sum `dependent' 

reghdfe `dependent' c.p_drillco  contstd_*, absorb(id_OG_pair state_year_pair lat_long1_year_pair) vce (cluster id_OG)

reghdfe `dependent' c.p_drillco#c.regulatory_risk  contstd_*, absorb(id_OG_year_pair state_year_pair lat_long1_year_pair) vce (cluster id_OG)

reghdfe `dependent' c.p_drillco#c.high_liability  contstd_*, absorb(id_OG_year_pair state_year_pair lat_long1_year_pair) vce (cluster id_OG)


local dependent "d_pollution"
sum `dependent' 
reghdfe `dependent' c.p_drillco  contstd_*, absorb(id_OG_pair state_year_pair lat_long1_year_pair) vce (cluster id_OG)

reghdfe `dependent' c.p_drillco#c.regulatory_risk  contstd_*, absorb(id_OG_year_pair state_year_pair lat_long1_year_pair) vce (cluster id_OG)

reghdfe `dependent' c.p_drillco#c.high_liability  contstd_*, absorb(id_OG_year_pair state_year_pair lat_long1_year_pair) vce (cluster id_OG)

*************************************************
*Table 6
*************************************************
use baseline.dta, clear

local dependent "y_pollution"
sum `dependent'

reghdfe  `dependent' c.d_sensible##c.post##c.y2017 contstd_*, absorb(id_OG_year lat_long1_year state_year) vce (cluster id_OG)

reghdfe  `dependent' c.d_sensible##c.post##c.federal_court contstd_*, absorb(id_OG_year lat_long1_year state_year) vce (cluster id_OG)

local dependent "d_pollution"
sum `dependent'

reghdfe `dependent' c.d_sensible##c.post##c.y2017 contstd_*, absorb(id_OG_year lat_long1_year state_year) vce (cluster id_OG)

reghdfe  `dependent' c.d_sensible##c.post##c.federal_court contstd_*, absorb(id_OG_year lat_long1_year state_year) vce (cluster id_OG)


*************************************************
*Table 7 - Panel A
*************************************************
use baseline.dta, clear

local dependent "l_production"
sum `dependent' 

 reghdfe  `dependent' post, absorb(id_OG year) vce (cluster id_OG)

 reghdfe  `dependent' post contstd_vertical contstd_horizontal, absorb(id_OG state_year lat_long1_year) vce (cluster id_OG)

reghdfe `dependent' c.post#c.regulatory_risk  contstd_vertical contstd_horizontal, absorb(id_OG_year state_year lat_long1_year) vce (cluster id_OG)

reghdfe `dependent' c.post#c.high_liability  contstd_vertical contstd_horizontal, absorb(id_OG_year state_year lat_long1_year) vce (cluster id_OG)


local dependent "l_total_production"
sum `dependent' 

 reghdfe  `dependent' post, absorb(id_OG year) vce (cluster id_OG)

 reghdfe  `dependent' post contstd_vertical contstd_horizontal, absorb(id_OG state_year lat_long1_year) vce (cluster id_OG)

reghdfe `dependent' c.post#c.regulatory_risk  contstd_vertical contstd_horizontal, absorb(id_OG_year state_year lat_long1_year) vce (cluster id_OG)

reghdfe `dependent' c.post#c.high_liability  contstd_vertical contstd_horizontal, absorb(id_OG_year state_year lat_long1_year) vce (cluster id_OG)



*************************************************
*Table 7 - Panel B
*************************************************
use baseline.dta, clear

*Natural experiment:
local dependent "l_production"
sum `dependent' 

reghdfe `dependent' c.d_sensible##c.post##c.federal_court contstd_vertical contstd_horizontal, absorb(id_OG_year lat_long1_year state_year) vce (cluster id_OG)

reghdfe `dependent' c.d_sensible##c.post##c.y2017 contstd_vertical contstd_horizontal, absorb(id_OG_year lat_long1_year state_year) vce (cluster id_OG)

*Natural experiment:
local dependent "l_total_production"
reghdfe `dependent' c.d_sensible##c.post##c.federal_court contstd_vertical contstd_horizontal, absorb(id_OG_year lat_long1_year state_year) vce (cluster id_OG)

reghdfe `dependent' c.d_sensible##c.post##c.y2017 contstd_vertical contstd_horizontal, absorb(id_OG_year lat_long1_year state_year) vce (cluster id_OG)


*************************************************
*Table 8 - Panel A
*************************************************
use baseline.dta, clear
local dependent "confidential"
reghdfe `dependent' c.post  contstd_*, absorb(id_OG state_year lat_long1_year) vce (cluster id_OG)

reghdfe `dependent' c.post#c.regulatory_risk contstd_*, absorb(id_OG_year state_year lat_long1_year) vce (cluster id_OG)

reghdfe `dependent' c.post#c.high_liability contstd_*, absorb(id_OG_year state_year lat_long1_year) vce (cluster id_OG)

*******
local dependent "d_confidential"
reghdfe `dependent' c.post contstd_*, absorb(id_OG state_year lat_long1_year) vce (cluster id_OG)

reghdfe `dependent' c.post#c.regulatory_risk  contstd_*, absorb(id_OG_year state_year lat_long1_year) vce (cluster id_OG)

reghdfe `dependent' c.post#c.high_liability contstd_*, absorb(id_OG_year state_year lat_long1_year) vce (cluster id_OG)


*************************************************
*Table 8 - Panel B
*************************************************
use baseline.dta, clear
local dependent "confidential"
sum `dependent' 
reghdfe `dependent' c.d_sensible##c.post##c.federal_court contstd_*, absorb(id_OG_year state_year lat_long1_year) vce (cluster id_OG)

reghdfe `dependent' c.d_sensible##c.post##c.y2017 contstd_*, absorb(id_OG_year state_year lat_long1_year) vce (cluster id_OG)

*Natural experiment:
local dependent "d_confidential"
sum `dependent' 
reghdfe `dependent' c.d_sensible##c.post##c.federal_court contstd_*, absorb(id_OG_year state_year lat_long1_year) vce (cluster id_OG)

reghdfe `dependent' c.d_sensible##c.post##c.y2017 contstd_*, absorb(id_OG_year state_year lat_long1_year) vce (cluster id_OG)
